<template>
  <el-container class="main_con" style="padding-bottom:0px">
       <ufrom @submit="saveData" ref="ufrom">
        <el-form size="medium" label-width="100px">
          <div class="setting_body_item">
            <div class="header">交易设置</div>
            <div class="conetnt edit_con">
              <div class="edit_content">
                <el-form-item label="未付款订单">
                  <el-radio-group v-model="obj.configuration.order_is_close">
                    <el-radio :label="0">永不关闭</el-radio>
                    <el-radio :label="1">自定义关闭时间</el-radio>
                  </el-radio-group>
                </el-form-item>

                <el-form-item v-if="obj.configuration.order_is_close == 1" label="">
                  <div class="fks">
                    订单拍下
                    <el-input v-model="obj.configuration.order_close_time" style="width:180px;margin-right:10px;margin-left:10px">
                      <template slot="append">
                        分钟
                      </template>
                    </el-input>
                    内未付款，自动关闭订单
                    <div style="color:#909399;font-size:12px;">订单取消时间必须在20-1440分钟之间</div>
                  </div>
                </el-form-item>

                <el-form-item label="自动收货">
                  <el-radio-group v-model="obj.configuration.is_auto_receiving">
                    <el-radio :label="0">不自动收货</el-radio>
                    <el-radio :label="1">自定义收货时间</el-radio>
                  </el-radio-group>
                </el-form-item>

                <el-form-item v-if="obj.configuration.is_auto_receiving == 1" label="">
                  <div class="fks">
                    发货
                    <el-input v-model="obj.configuration.receiving_time" style="width:180px;margin-right:10px;margin-left:10px">
                      <template slot="append">
                        天
                      </template>
                    </el-input>
                    后自动收货
                    <div style="color:#909399;font-size:12px;">自动确认收货时间必须在7-30天之间</div>
                  </div>
                </el-form-item>
                <el-form-item label="订单完结">
                  <div class="fks">
                    订单收货
                    <el-input v-model="obj.configuration.order_end_time" style="width:180px;margin-right:10px;margin-left:10px">
                      <template slot="append">
                        天
                      </template>
                    </el-input>
                    后自动完结订单
                    <!-- <div style="color:#909399;font-size:12px;">自动确认收货时间必须在7-30天之间</div> -->
                  </div>
                </el-form-item>
                <el-form-item label="分销佣金">
                  <div class="fks">
                    订单完结
                    <el-input v-model="obj.configuration.agent_get_money_time" style="width:180px;margin-right:10px;margin-left:10px">
                      <template slot="append">
                        天
                      </template>
                    </el-input>
                    后,获得分销佣金
                    <!-- <div style="color:#909399;font-size:12px;">订单取消时间必须在20-1440分钟之间</div> -->
                  </div>
                </el-form-item>
                <!--
                <el-form-item label="交易增强">
                  <el-radio-group v-model="obj.configuration.deal_enhance">
                    <el-radio :label="1">开启</el-radio>
                    <el-radio :label="0">关闭</el-radio>
                  </el-radio-group>
                  <div style="color:#909399;font-size:12px;">开启后进入商城首页时会自动弹出未支付订单提示</div>
                </el-form-item>

                -->
                <el-form-item label="发票设置">
                  <el-radio-group v-model="obj.configuration.is_invoice">
                    <el-radio :label="1">开启</el-radio>
                    <el-radio :label="0">关闭</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="订单评价">
                  <el-radio-group v-model="obj.configuration.order_evaluate">
                    <el-radio :label="1">开启</el-radio>
                    <el-radio :label="0">关闭</el-radio>
                  </el-radio-group>
                </el-form-item>

                <el-form-item label="显示评价">
                  <el-radio-group v-model="obj.configuration.is_show_evaluate">
                    <el-radio :label="1">开启</el-radio>
                    <el-radio :label="0">关闭</el-radio>
                  </el-radio-group>
                </el-form-item>

                <el-form-item label="评价审核">
                  <el-radio-group v-model="obj.configuration.audit_evaluate">
                    <el-radio :label="1">开启</el-radio>
                    <el-radio :label="0">关闭</el-radio>
                  </el-radio-group>
                </el-form-item>
              </div>
            </div>
          </div>
        </el-form>
       </ufrom>
  </el-container>
</template>

<script>
import {addSiteConfig, editSiteConfig, getSiteConfig} from '@/api/mall/setting';
export default {
  data() {
    return {
      isLoading: false,
      checkList: [],
      obj: {
        type: 'tradeSetting',
        status: 1,
        configuration: {
          agent_get_money_time: 0,
          order_is_close: 0,
          order_close_time: 0,
          is_auto_receiving: 0,
          receiving_time: 0,
          order_end_time:0,
          deal_enhance: 0,
          invoice: [],
          order_evaluate: 1,
          is_show_evaluate: 1,
          audit_evaluate: 1,
          is_invoice: 0
        }
      }
    };
  },
  components: {},
  mounted() {
    this.getConfig('tradeSetting');
  },
  methods: {
    //获取站点配置数据
    getConfig(type) {
      getSiteConfig(type)
        .then(res => {
          if (res.msg) {
            this.obj = res.msg;
          }
        })
        .catch(e => {
        });
    },
    //保存数据
    saveData() {
      if (this.obj.update_time) {
        //更新
        editSiteConfig(this.obj)
          .then(res => {
           this.$refs.ufrom.init()
            this.getConfig('tradeSetting');
          })
          .catch(e => {
            this.$refs.ufrom.init()
          });
      } else {
        //新增
        addSiteConfig(this.obj)
          .then(res => {
            this.$refs.ufrom.init()
            this.getConfig('tradeSetting');
          })
          .catch(e => {
            this.$refs.ufrom.init()
          });
      }
    }
  }
};
</script>

